﻿@model IEnumerable<Von.Web.Structs.SkinInfo>
@{
    ViewData["Title"] = "皮肤管理管理";
}
<h2>皮肤管理<a class="btn btn-link" onclick="NewSkin()">新建皮肤管理</a></h2>
<table id="SkinList" class="table">
    <thead>
        <tr>
            <th>名称</th>
            <th>管理皮肤</th>
            <th>应用皮肤</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@Html.DisplayFor(modelItem => item.SkinName)</td>
                <td>@Html.DisplayFor(modelItem => item.AdminSkin)</td>
                <td>@Html.DisplayFor(modelItem => item.AppSkin)</td>
                <td>
                    <input type="button" class="btn-link" onclick="EditSkin(this, '@item.ID')" value="编辑"> | 
                    <input type="button" class="btn-danger" onclick="DeleteSkin(this, '@item.ID')" value="删除">
                </td>
            </tr>
        }
    </tbody>
</table>
<!-- 模态框（Modal） -->
<div class="modal fade" id="SkinEditor" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true" data-mode="new">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="background-color:aquamarine;">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="ModalLabel">皮肤管理编辑</h4>
            </div>
            <div class="modal-body">
                <div class="input-group">
                    <label for="SkinName" class="input-group-addon column-prompt">名称</label>
                    <input id="SkinName" class="form-control" />
                </div>
                <div class="input-group">
                    <label for="AdminSkin" class="input-group-addon column-prompt">管理皮肤</label>
                    <input id="AdminSkin" class="form-control" />
                </div>
                <div class="input-group">
                    <label for="AppSkin" class="input-group-addon column-prompt">应用皮肤</label>
                    <input id="AppSkin" class="form-control" />
                </div>
            </div>
            <div class="modal-footer">
                <input type="hidden" id="ID" />
                <div class="form-group">
                    <input value="保存" class="btn btn-default" onclick="SaveSkin()" />
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<script type="text/javascript">

    function NewSkin() {
        von.selectRow();
        von.editor.clear();
        von.editor.display("new");
    }
    function EditSkin(btn, id) {
        von.selectRow(btn);
        AjaxPostData("@Url.Ajax("GetBySkin")", { ID: id }, function (data) {
            von.editor.setData(data);
            von.editor.display("edit");
        });
    }
    function DeleteSkin(btn, id) {
        if (confirm('确定删除吗？')) {
            von.selectRow(btn);
            AjaxPostData('@Url.Ajax("DeleteSkin")', { 'ID': id }, function (result) { von.deleteRow(); });
        }
    }
    function CheckSkin(){
        var msg = "";
        if($("#ID").val() == "") msg += "序号必须录入，不允许为空。";
        return msg;
    }
    function SaveSkin() {
        var msg = CheckSkin();
        if (msg != "") return SysWarning(msg);
        var data = {};
        von.editor.getData(data);
        if (von.editor.mode == "new") AjaxPostData("@Url.Ajax("AddSkin")", data, function (data) { von.appendRow(von.getHtml(data)); von.editor.close(); });
        else AjaxPostData("@Url.Ajax("EditSkin")", data, function (data) { von.replaceRow(von.getHtml(data)); von.editor.close(); });
    }
</script>
@Html.Import(Von.Web.Html.EImportSection.BodyTrailler, "SkinInit",
    @<script>
        var von = VonGrid({
            app: "Skin",
            keyName: "ID",
            displayFields: ["ID", "SkinName", "AdminSkin", "AppSkin"],
            fields: ["ID", "SkinName", "AdminSkin", "AppSkin"]
        });
    </script>
)
